﻿using System;
using System.Linq.Expressions;

namespace Kernelx.Extensions._Internals.Clauses.ClauseElement2Expressions
{
    internal class CreateExpressionMetadata : ICreateExpressionMetadata
    {
        private readonly Func<Expression, Expression, Expression> _createBody;
        private readonly Func<object, Type, Expression> _createConstant;
        public CreateExpressionMetadata(Func<Expression, Expression, Expression> createBody, Func<object, Type, Expression> createConstant = null)
        {
            _createBody = createBody;
            _createConstant = createConstant ?? Expression.Constant;
        }
        public virtual Expression CreateBody(Expression member, Expression constant) => _createBody(member, constant);

        public virtual Expression CreateConstant(object value, Type propType) => _createConstant(value, propType);

    }

}
